//  xmlHttpRequest

function datosServidor() {
};
datosServidor.prototype.iniciar = function() {
	try {
		// Mozilla / Safari
		this._xh = new XMLHttpRequest();
	} catch (e) {
		// Explorer
		var _ieModelos = new Array(
		'MSXML2.XMLHTTP.5.0',
		'MSXML2.XMLHTTP.4.0',
		'MSXML2.XMLHTTP.3.0',
		'MSXML2.XMLHTTP',
		'Microsoft.XMLHTTP'
		);
		var success = false;
		for (var i=0;i < _ieModelos.length && !success; i++) {
			try {
				this._xh = new ActiveXObject(_ieModelos[i]);
				success = true;
			} catch (e) {
				// Implementar manejo de excepciones
			}
		}
		if ( !success ) {
			// Implementar manejo de excepciones, mientras alerta.
			return false;
		}
		return true;
	}
}

datosServidor.prototype.ocupado = function() {
	estadoActual = this._xh.readyState;
	return (estadoActual && (estadoActual < 4));
}

datosServidor.prototype.procesa = function() {
	if (this._xh.readyState == 4 && this._xh.status == 200) {
		this.procesado = true;
	}
}

datosServidor.prototype.enviar = function(urlget,datos) {
	if (!this._xh) {
		this.iniciar();
	}
	if (!this.ocupado()) {
		this._xh.open("GET",urlget,false);
		this._xh.send(datos);
		if (this._xh.readyState == 4 && this._xh.status == 200) {
			return this._xh.responseText;
		}
		
	}
	return false;
}



function _gr(reqseccion,divcont) {
	remotos = new datosServidor;
	nt = remotos.enviar(reqseccion,"");
	document.getElementById(divcont).innerHTML = rt;
}



function rateFile(rating_file,id_file)  {
		remotos = new datosServidor;
		rt = remotos.enviar('../../ss_saveFileRate.php?rating_file='+rating_file+'&id_file='+id_file);
		rating_file = rating_file * 25;
		document.getElementById('current-rating').style.width = rating_file+'px';
}

function voteComment(value,id_comment)  {
		remotos = new datosServidor;
		nt = remotos.enviar('../../ss_saveFileVoteComment.php?id_comment='+id_comment+'&value='+value);
		
		
		
		document.getElementById('dedodown'+id_comment).src= '/skins/soundshare/dedo_gray_down.png';
		document.getElementById('dedoup'+id_comment).src= '/skins/soundshare/dedo_gray_up.png';
    document.getElementById('linkdedodown'+id_comment).href= '';
    document.getElementById('linkdedoup'+id_comment).href= '';
    
    
    //value = parseInt(value);
    valorvoto = document.getElementById('countervote'+id_comment).innerHTML*1;
    
    
    if (value == 1){
      valorvoto = (valorvoto) + 1;
      //alert (valorvoto);
    }
    else if (value == -1){
      valorvoto = (valorvoto) - 1;
    
    }
    document.getElementById('countervote'+id_comment).innerHTML = valorvoto;
    
    //document.getElementById('dedodown'+id_comment).href.style.visibility="hidden";
    
}
